package com.soup.view.component;

import com.soup.view.value.ColorValue;

import javax.swing.*;
import java.awt.*;

public class MassageTip {
    public static void showMassage(final MeFrame parent, final String massage) {

        new Thread() {
            @Override
            public void run() {
                Dialog dialog = new Dialog(parent);
                dialog.setSize(300, 40);
                Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
                dialog.setLocation((int)(screen.getWidth()-dialog.getWidth())/2,10);
                dialog.setBackground(ColorValue.ContextBackground);
                dialog.setUndecorated(true);
                dialog.setLayout(new FlowLayout(FlowLayout.CENTER));
                JLabel msg = new JLabel(massage);
                msg.setForeground(ColorValue.ContextForeground);
                msg.setFont(new Font("幼圆", Font.BOLD, 20));
                dialog.add(msg);
                dialog.setVisible(true);
                try {
                    Toolkit.getDefaultToolkit().beep();
                    Thread.sleep(1500);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                dialog.dispose();
            }
        }.start();
    }
}
